﻿using AutofacDemo1.Services;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AutofacDemo1.Controllers
{

    [ApiController]
    [Route("userManage")]
    public class UserManageController:ControllerBase
    {
        // 这里通过属性进行注入
        public IUserService service { get; set; }

        [HttpGet("hello")]
        public string Hello()
        {
            if(service == null) return "Error";

            var controllersTypesInAssembly =
                typeof(UserManageController).Assembly.GetExportedTypes()
            .Where(type => typeof(ControllerBase).IsAssignableFrom(type))
            .ToArray();

            foreach( var a in controllersTypesInAssembly)
            {
                Console.WriteLine(a.Name);
            }

            return service.Hello() ;
        }


    }
}
